package com.halloon.android.ui.activity;

import android.support.v4.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.halloon.android.R;
import com.halloon.android.ui.fragment.PublishFragment;
import com.halloon.android.ui.fragment.PublishFragment.PublishFragmentCallback;
import com.halloon.android.ui.fragment.TabMainPageFragment;

public class MainPageActivity extends BaseMultiFragmentActivity implements PublishFragmentCallback{
	
	@Override
	protected Fragment onCreatePane() {
		mFragmentContainer.add(new TabMainPageFragment());
		((TabMainPageFragment) getFragmentDec(1)).setTweetState(TabMainPageFragment.MAIN_TIMELINE_TWEET);
		
		return getFragmentDec(1);
	}
	
	@Override
	public void setupPublishFragment() {
		mFragmentContainer.add(new PublishFragment());
		FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
		fragmentTransaction.setCustomAnimations(R.anim.fragment_slide_right_enter, 
				                                R.anim.fragment_slide_left_exit, 
				                                R.anim.fragment_slide_left_enter, 
				                                R.anim.fragment_slide_right_exit);
		fragmentTransaction.add(R.id.root_container, getFragmentDec(1));
		fragmentTransaction.hide(getFragmentDec(2));
		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.commit();
	}
	
	@Override
	public void setupAroundTweetFragment() {
		mFragmentContainer.add(new TabMainPageFragment());
		((TabMainPageFragment) getFragmentDec(1)).setTweetState(TabMainPageFragment.AROUND_TWEET);
		Bundle bundle = new Bundle();
		bundle.putString("name", "null");
		bundle.putString("nick", "null");
		getFragmentDec(1).setArguments(bundle);
		FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
		fragmentTransaction.setCustomAnimations(R.anim.fragment_slide_right_enter, 
				                                R.anim.fragment_slide_left_exit, 
				                                R.anim.fragment_slide_left_enter, 
				                                R.anim.fragment_slide_right_exit);
		fragmentTransaction.add(R.id.root_container, getFragmentDec(1));
		fragmentTransaction.hide(getFragmentDec(2));
		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.commit();
	}
	
	@Override
	public void destroyPublishFragment(){
		backStackAction();
	}

}
